﻿@model UserIndexViewModel
@{
    var x = Html.X();
    Html.EnableClientValidation();
}


@(x.Window().Layout(LayoutType.Fit)
        .CloseAction(CloseAction.Destroy)
        .Width(1000).Height(600)
        .Items(
            x.FormPanel().Default().Layout(LayoutType.Fit)
                .Items(
                    x.GridPanel()
                        .Store(x.StoreForModel().RemoteFilter(true)
                            .Proxy(x.AjaxProxy().Url(Url.Action("GetUsersNotInRolePaged", "Role", new { roleId = Model.Id })).Post().Reader(x.JsonReader().RootProperty("data")))
                            .RemoteSort(true).RemotePaging(true).PageSize(25)
                            .SorterFor(Model, m => m.Id, Ext.Net.SortDirection.DESC))
                        .SelectionModel(x.CheckboxSelectionModel().Mode(SelectionMode.Multi))
                        .ColumnModel(
                            x.RowNumbererColumn().Align(ColumnAlign.End).Width(60),
                            x.ColumnFor(Model, m => m.UserName),
                            x.ColumnFor(Model, m => m.Email)
                        )
                        .BottomBar(x.PagingToolbar().ItemsFromPartial("~/Views/Shared/_PagingToolbarPartial.cshtml"))
                        .EmptyText("无数据。")
                        .View(Html.X().GridView().StripeRows(true).TrackOver(true))
                )
                .Buttons(
                    x.Button().Text("提交").Icon(Icon.Disk)
                        .DirectEvents(de =>
                        {
                            de.Click.Action = "AddUser";
                            de.Click.ExtraParams.Add(new Parameter("userIds", "App.Grid.getSelectedIds(this.up('form').down('grid'))", ParameterMode.Raw));
                            de.Click.ExtraParams.Add(new Parameter("roleId", Model.Id.ToString(), ParameterMode.Value));
                            de.Click.ExtraParams.Add(new Parameter("refreshGrid", Request["RefreshGrid"], ParameterMode.Value));
                            de.Click.EventMask.ShowMask = true;
                            de.Click.EventMask.Msg = "正在提交...";
                            de.Click.Success = "this.up(\"window\").close();";
                        }),
                    x.Button().Text("关闭").Icon(Icon.Cancel).OnClientClick("App.Edit.CloseWindow(this)")
                )
        )
)